<?php
include './AcessoBD.php';

final class TransactionBD{
    
    private static $conexao;
    
    private function __construct() {
        
    }
    
    public static function abre(){
        if(empty(self::$conexao)){
            self::$conexao = AcessoBD::abreConexao();
            self::$conexao->beginTransaction();
        }
    }
    
    public static function getConexao(){
        return self::$conexao;
    }
    
    public static function rollback(){
    
        if(self::$conexao){
            self::$conexao->rollback();
            self::$conexao = NULL;
        }    
    }
    
    public static function fechar(){
        if(self::$conexao){
            self::$conexao->commit();
            self::$conexao = NULL;
        }
    }
}
/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

